home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / getBrushes.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.5 KB  |  107 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date: Jan 99
  22. //
  23. //  Author:        APP
  24. //
  25. //  Description:
  26. //      This finds all brushes in the selection list,
  27. //        0 - only return brushes which are picked directly
  28. //        1 - return brushes which are picked directly, or
  29. //            indirectly though their strokes
  30. //        2 - return brushes which are picked directly,
  31. //            indirectly though their strokes, or indirectly
  32. //            through their curves
  33. //        3 - return brushes which are picked directly,
  34. //            indirectly though their strokes, or indirectly
  35. //            through their curves, or indirectly through
  36. //            surfaces with COS's.
  37. //
  38. //  Returns:
  39. //        $string[] - a list of all brushes selected.
  40. //        If a brush is selected more than once it will
  41. //        only appear once in the list.
  42. //
  43. global proc string[] getBrushes( int $filter )
  44. {
  45.     string $brushes[];
  46.     int    $idx = 0;
  47.  
  48.     if ($filter > 0) {
  49.         int $val = $filter - 1;
  50.         string $strokes[] = getStrokes( $val );
  51.         // Walk through all strokes returned and add their associated brushes to our list.
  52.         string $stroke;
  53.         for ($stroke in $strokes) {
  54.             if ($stroke != "") {
  55.                 string $attr = $stroke + ".brush";
  56.                 string $result = `connectionInfo -sfd $attr`;
  57.                 string $buffer[];
  58.                 int $num = `tokenize $result "." $buffer`;
  59.                 $brushes[ $idx ] = $buffer[0];
  60.                 ++$idx;
  61.             }
  62.         }
  63.     }
  64.  
  65.     // Now add any brushes which are on the pick list directly.
  66.     string $selectionList[] = `ls -sl -l`;
  67.     string $selection;
  68.     for ($selection in $selectionList) {
  69.         if (`nodeType $selection` == "brush") {
  70.                 $brushes[$idx] = $selection;
  71.                 ++$idx;
  72.         }
  73.     }
  74.  
  75.     // Now filter any duplicates out of the brush list.
  76.     string $returnBrushes[];
  77.     int    $brushesSize = size( $brushes );
  78.     if ( $brushesSize != 0) {
  79.         string $sortedBrushes[] = `sort $brushes`;
  80.         int $i;
  81.         int $idx = 0;
  82.         $returnBrushes[ $idx ] = $sortedBrushes[ 0 ];
  83.         for ($i = 1; $i < $brushesSize; ++$i) {
  84.             if ($sortedBrushes[ $i ] != $returnBrushes[ $idx ]) {
  85.                 // It is a unique entry.
  86.                 ++$idx;
  87.                 $returnBrushes[ $idx ] = $sortedBrushes[ $i ];
  88.             }
  89.         }
  90.         if ( $sortedBrushes[0] != $brushes[0] ) {
  91.             // We have changed the lead brush
  92.             for ($i = 1; $i < $brushesSize; ++$i) {
  93.                 // Find the lead brush in the unique array.
  94.                 if ( $sortedBrushes[ $i ] == $brushes[0] ) {
  95.                     // Found it.
  96.                     $brushes[0]          = $sortedBrushes[ 0 ];
  97.                     $sortedBrushes[ 0 ]  = $sortedBrushes[ $i ];
  98.                     $sortedBrushes[ $i ] = $brushes[0];
  99.                     $i = $brushesSize; // break out of the loop
  100.                 }
  101.             }
  102.         }
  103.     }
  104.         
  105.     return ( $returnBrushes );
  106. }
  107.